# 写一个程序，测试此网络内,
# 192.168.1.1 ~  192.168.1.254 之间的机器，哪些开机，哪些关机

import subprocess
import threading  # 导入线程模块

def ping(host_ip):
    cmd = 'ping -c2 %s &> /dev/null' % host_ip
    r = subprocess.run(cmd, shell=True)
    if r.returncode == 0:
        print(host_ip, '通')
    else:
        print(host_ip, '不通')

if __name__ == '__main__':
    for x in range(1, 255):
        # ipv4 = '192.168.0.%s' % x
        ipv4 = '182.61.200.%s' % x
        # ping(ipv4)
        t = threading.Thread(target=ping, args=(ipv4,))
        t.start()
    print('主线程结束运行！！！')